package com.qiangqiang.controller;

import com.qiangqiang.dto.VisitDTO;
import com.qiangqiang.entity.Visit;
import com.qiangqiang.service.VisitService;
import com.qiangqiang.util.ResultVOUtil;
import com.qiangqiang.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by q on 2018/2/20.
 */
@RestController
@RequestMapping("/visit")
public class VisitController {

    @Autowired
    private VisitService visitService;

    @RequestMapping("/findByTime")
    public ResultVO<List<VisitDTO>> findAllByTimeQuantum(@RequestParam("startTime") String startTime,
                                                         @RequestParam("endTime") String endTime){
        return ResultVOUtil.success(visitService.findAllByTimeQuantum(startTime,endTime));
    }

    @PostMapping("/findBySid")
    public ResultVO<List<VisitDTO>> findAllBySid(@RequestParam("id") String sId){
        return ResultVOUtil.success(visitService.findAllBySid(sId));
    }

    @RequestMapping("/add")
    public ResultVO add(Visit visit){
        return ResultVOUtil.success(visitService.add(visit));
    }
}
